# Contributor: Dhruvin Gandhi <contact@dhruvin.dev>
# Maintainer: Dhruvin Gandhi <contact@dhruvin.dev>
pkgname=hledger-iadd
pkgver=1.3.19
pkgrel=2
pkgdesc="A terminal UI as drop-in replacement for hledger add"
url="https://github.com/hpdeifel/hledger-iadd#readme"
arch="aarch64 x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="
	cabal
	ghc
	libffi-dev
	ncurses-dev
	zlib-dev
	"
_llvmver=14
options="net"
source="https://hackage.haskell.org/package/hledger-iadd-$pkgver/hledger-iadd-$pkgver.tar.gz
	cabal.project.freeze"

export CABAL_DIR="$srcdir"/cabal
export PATH="/usr/lib/llvm$_llvmver/bin:$PATH"

cabal_update() {
        cd $builddir
        cabal v2-update
        (
                cd "$builddir"
                cabal v2-freeze --shadow-installed-packages
                mv cabal.project.freeze "$startdir/"
        )
}

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

check() {
	cabal test
}

package() {
	install -Dm755 "$(cabal list-bin hledger-iadd)" "$pkgdir"/usr/bin/hledger-iadd
}

sha512sums="
7b4caf0eedea1d4d869a7bc96d024e9ab5569d3d73db3de8b2ce431eded1aca61ffdbfc19f05f2797e95f4043e5eb0416042f3028fe881166a2d40ae17eb6238  hledger-iadd-1.3.19.tar.gz
3faebcb321e389bef25c533acbdadf8475974c2623ed47b549acd8ed4b3ebe87621fa970b72c877efed2deecd5ac89db9e71e5a651b05008038812ed02cc692e  cabal.project.freeze
"
